import { isArrayLike } from "./each";
import identity from "../util/identity";
import map from './map'
import values from '../object/values'
import isArray from "../object/isArray";
import isString from "../object/isString";

var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
export default function toArray(obj) {
  if (!obj) return [];
  if (isArray(obj)) return Array.prototype.slice.call(obj);
  if (isString(obj)) {
    // Keep surrogate pair characters together
    return obj.match(reStrSymbol);
  }
  if (isArrayLike(obj)) return map(obj, identity);
  return values(obj);
}